<?php 
require_once 'includes/funciones.php';
conexion();
require_once 'is_login.php';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
  #fotosdebates{
    width:550px;
	height:130px;
	margin: 0px 100px 10px 30px;
	padding-left:30px;
	}
	
	.fieldsetfront span{
	float:left;
	width:100px;
}

.fieldsetfront input textarea{
	float:left;
	width:280px;
}
	
</style>


<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><?php titulo();?></title>
<link rel="STYLESHEET" type="text/css" href="estilo.css">
<link rel="shortcut icon" href="favicon.ico">
<script type="text/javascript" src="plugins/jquery.js"></script>
<script type="text/javascript" src="plugins/jquery_validate/jquery.validate.js"></script>
<script type="text/javascript" src="plugins/jquery-lightbox-0.5/js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="plugins/jquery-lightbox-0.5/css/jquery.lightbox-0.5.css" media="screen" />

    <script type="text/javascript">
    $(document).ready(function(){	
    	$(function() {
    		$('.fotolistadodebate a').lightBox(); // Select all links in object with gallery ID
    		
    	}); 
    });
    </script>

<script>
  $(document).ready(function(){

	$("#commentForm").validate({
		rules: {
			name: {
				required: true,
				},
				comment: {
					required: true,
					},
				
				email: {
					required: true,
					email: true
			},
		},
		messages: {
			name: {
				required: "Debe ingresar su nombre",
			
			},
			comment: {
				required: "Debe completar el comentario",
			
			},
			email: "Ingrese una direccion de email valida",

		}
	});

  });
</script>

</head>

<body>


<div id="contenedor">

  	<?php
	require_once("includes/encabezado.php");

	?>
  	<!--fin de encabezado-->

<div id="contentleft">

<?php
	//include_once("includes/banner.php");
        
        $idnoticia=sqlint($_GET['var'])
?>

	
<div id="contentcenter">
    <div id="socialmedia">        
   <!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_clickback":true,"data_track_addressbar":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e0fb56109b91695"></script>
<!-- AddThis Button END -->
<br/>
<?php
echo '<iframe src="http://www.facebook.com/plugins/like.php?href=www.zonauniversitaria.com.ar/ver_noticia.php?var='.$idnoticia.'"
        scrolling="no" frameborder="0"
        style="border:none; width:450px; height:50px"></iframe>';
?>
        
    </div>
		


		<?php					
			$idnoticia=sqlint($_GET['var']);# Limpio la variable por SQLi
			$req=mysql_query("select * from news where id=$idnoticia and is_published=1");
			
			if(mysql_num_rows($req) != 0){	
					
					$rownoticias = mysql_fetch_array($req); 				
					$id_news = $rownoticias['id'];
					$summary=$rownoticias['summary'];
					$summary=substr($summary,0,400);
					$title=$rownoticias['title'];
					$title=substr($title,0,140);
					$created=$rownoticias['created'];	
					$content=$rownoticias['content'];
					$categorie=$rownoticias['id_categories'];
					
					
					$created=explode(" ", $created);
					
					$date=$created[0];
					$time=$created[1];
						
					$rowcategorie=existe("id", "categories", $categorie);
	
	
					echo '<div class="categoria">';
					echo $rowcategorie['description'];
					echo '</div>';#cierre categoria

					echo '<div class="titulo">';
					echo '<strong>'.$title.'</strong>';
					echo '</div>';
					echo "<br>";
					echo '<div class="fecha">'.$date.' | '.$time.' hs. </div>';

					
					echo '<br>';
					echo '<div class="copete">'.$summary.'</div>';
					
					
					$respfoto=mysql_query("select * from images_news where id_news=$id_news");

					if(mysql_num_rows($respfoto)!=0){
						
					if($categorie==14){//I asking if is one debate
						echo '<div id="fotosdebates">';
						while($rows = mysql_fetch_array($respfoto)) {
							
							$folder=$rows['folder']; //GET DATA FROM DB
							$foto=$rows['url'];
							$comment=$rows['comment'];
							echo '<div class="fotolistadodebate">';
							
						    	echo '<a href="'.$folder.$foto.'"><img width="165" height="108" src="'.$folder.$foto.'"/></a>';
								
							echo '</div>';#cierre <div id=fotitonotocialistado
								
						}
						echo "</div>";
					} 
					else {
						
					
							while($rows = mysql_fetch_array($respfoto)) 
							{
								$folder=$rows['folder']; //GET DATA FROM DB
								$foto=$rows['url'];
								$comment=$rows['comment'];
							
							    echo "<div class='imagenes'><br>";
								    echo "<br>";
								    echo '<img width="400"  height="280" src="'.$folder.$foto.'" />';
								    echo "<br><br>";
									echo $comment;
							    echo "</div>";
						
							}#while
						}//CLOSE ELSE	

					
					}
									
					
					echo '<div class="contenttext">';
					echo $content;
					echo '</div>';
					
			}
			
		else{
			echo '<div class="imagenes"><img src=imagenes/zambo404.JPG></div>';
		}	
?>


<?php 
###Comentario para DEBATE

if($categorie==14){?>
<br/><br/>
<fieldset style="width:550px" class="fieldsetfront">
        <legend>Ingrese su comentario</legend>
<form action="control_comentario.php" id="commentForm" name="commentForm" method="post">
<p><span>Autor:</span>
<input type="text" name="name" size="40" id="name">
</p>
<br>
<p><span>
Email (No sera publicado):</span>
<input type="text" name="email" size="40" id="email">
</p>
<br>
<p><span>
Comentario:</span>
<textarea name="comment" id="comment" cols="35" rows="5" wrap="physical"></textarea>
</p>

<input name="boton" type="hidden" id="boton" value="1"></input>
<input name="id_news" type="hidden" id="id_news" value="<?php echo $id_news ?>"></input>
<br>	
<br>
<div style="text-align:center;">
<input type="submit" class="buttonfront" value="Publicar">
</div>
</form>
</fieldset>
<?php 
	$com=mysql_query("select * from comments where id_news=$idnoticia");
		if(mysql_num_rows($com)!=0){
			echo '<div id="comentarios">';
								
						while($rowscom = mysql_fetch_array($com)) {
						echo '<div class="comentario">';
						
									echo '<div class="autor">';
											
												echo $rowscom['name'];
											 
											
											echo '<div class="fecha">';
												
												$created = $rowscom['created'];
												$created=explode(" ", $created);
												$date=$created[0];
												$time=$created[1];
												echo $date;
											echo '</div>';	 
								
										if(isset($_SESSION['usuario']["user"])){
											echo '<a href="control_comentario.php?id_news='.$id_news.'&id_comment='.$rowscom['id'].'&token='.$_SESSION['usuario']["token"].'">  <img style="border:0;" title="Borrar comentario" width="15" height="15" src="imagenes/del_comment2.png"></a>';
										}		
									
											
									echo '</div>';
									
									
									
									echo '<div class="texto">';
										echo $rowscom['comment'];
									echo '</div>';
									
							
							echo '</div>';	
				
				}
			
			echo '</div>';	
		}

}

?>



</div> <!-- Cierre contentcenter -->


</div> <!-- Cierre contentleft -->
 



<div id="menuderecha" >
	<?php
	include_once("includes/menuderecha.php");
	?>
</div>	


<div id="publicidadbottom">
	<?php 
	include_once 'includes/publicidadbottom.php';	
	?>
</div>


<div id="piepagina">
<?php
include_once 'includes/pie.php';
?>
</div> 
  
  
  
  
</div> <!--fin de Contenedor-->


</body>
</html>
